package seiacpsjava.utilities;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.Random;

import javax.management.MXBean;

public class DataFileGenerator {
	
	
	
	public static void main(String[] args) {
		
	int size = 1000;
	int maxNumber = 1000;
	String filePath = "c:/comp6411_files/inputfile_1000Items.txt";
	
	StringBuffer output = new StringBuffer();
	Random randomNumberGenerator = new Random();
	
	for (int i=0; i<size;i++)
	{
		if ( i < size-1){
			output.append(randomNumberGenerator.nextInt(maxNumber) + ",");
		}else{
			output.append(randomNumberGenerator.nextInt(maxNumber));
		}
			
	}
	
	 writeToFile(output.toString(), filePath);
	 System.out.println("Finished writing file "+ filePath );
	}

	private static void writeToFile(String output, String filePath) {
		try{
			  // Create file 
			  FileWriter fstream = new FileWriter(filePath);
			  BufferedWriter out = new BufferedWriter(fstream);
			  out.write(output);
			  //Close the output stream
			  out.close();
		 }catch (Exception e){//Catch exception if any
			  System.err.println("Error: " + e.getMessage());
		 }
	}

}
